package com.netty.esc.utils;

/**
 * 记录方法执行时间工具类（记录别的执行时间也行。。）
 */
public class Timer {

    private Timer(){}

    private static final ThreadLocal<Long> TIMER = ThreadLocal.withInitial(System::currentTimeMillis);

    //初始化该线程起始时间
    public static void begin(){
        TIMER.set(System.currentTimeMillis());
    }

    //获得从调用begin方法到当前得时间
    public static long end(){
        return System.currentTimeMillis()-TIMER.get();
    }

}
